package org.example.nuaael;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @Author : zhangbo
 * @data : 2024/6/20
 * @description :
 */
@Slf4j
public class test {
    public static void main(String[] args) {

//        EvToGwCustomerAnulReptDto repDto = reportService.findByOpenid(openid);
        String resultConfig=" [\n" +
                "\t{\n" +
                "\t\t\"TopicTitle\":\"2024您与官微共度了哪些时光?\",\n" +
                "\t\t\"TopicId\":\"1\",\n" +
                "\t\t\"infos\":[\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"1\",\n" +
                "\t\t\t\t\"TM1\":\"太保官微与您在[]美好相遇,\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"1\",\n" +
                "\t\t\t\t\"TM2\":\"2024年，您曾来访过[]次,\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"1\",\n" +
                "\t\t\t\t\"TM3\":\"大多在[]时段,\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"1\",\n" +
                "\t\t\t\t\"TM4\":\"经鉴定，您是一位[]～\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"1\",\n" +
                "\t\t\t\t\"TM5\":\"（您总计节约了[]前往线下营业厅的时间。）,\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t}\n" +
                "\t\t]\n" +
                "\t},\n" +
                "\t{\n" +
                "\t\t\"TopicTitle\":\"您与太保最初邂逅在何时?\",\n" +
                "\t\t\"TopicId\":\"2\",\n" +
                "\t\t\"infos\":[\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"2\",\n" +
                "\t\t\t\t\"TM1\":\"[]，您的第一份保单生效了\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"2\",\n" +
                "\t\t\t\t\"TM2\":\"太保和您[]\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"2\",\n" +
                "\t\t\t\t\"TM3\":\"为您保驾护航[]\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t},\n" +
                "\t\t\t{\n" +
                "\t\t\t\t\"TMID\":\"2\",\n" +
                "\t\t\t\t\"TM4\":\"您还开通了个人养老金账户，走在品质养老前列～\",\n" +
                "\t\t\t\t\"TMSWITCH\":\"1\"\n" +
                "\t\t\t}\n" +
                "\t\t\t\n" +
                "\t\t]\n" +
                "\t}]";

        // 获取配置信息
        List<AnnualReportConfig> configList= JSONUtil.parseArray(resultConfig).toList(AnnualReportConfig.class);
        List<Map<String ,Object>>allList=new ArrayList<>();
        List<Map<String ,Object>>resultList=new ArrayList<>();
        for (AnnualReportConfig annualReportConfig : configList) {
            Map<String ,Object> resultMap=new HashMap<>();
            resultMap.put("TopicId",annualReportConfig.getTopicId());
            resultMap.put("TopicTitle",annualReportConfig.getTopicTitle());
            for (Map<String, String> info : annualReportConfig.getInfos()) {
                if(!"1".equals(info.get("TMSWITCH"))){
                    log.info("当前话术已关闭！");
                    break;
                }
                resultMap.put("Infos",annualReportConfig.getInfos());
            }
            resultList.add(resultMap);
        }
        allList.addAll(resultList);
    }
    public static <T> Function<Object,T> modelToDto(Class<T> clazz){
        return (object)-> BeanUtil.toBean(object, clazz);
    }
}
